package com.neusoft.elmboot.config;

import com.neusoft.elmboot.filter.JwtInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer  {

    @Value("${project.file.storage.path}")
    private String storagePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/**")
                .addResourceLocations("file:"+storagePath);
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        String [] pathArray = new String [] {
//                "/food/create","/food/update","/food/del",
//                "/business/create","/business/update","/business/del"
//        };
//        // 注册JwtInterceptor拦截器，并配置拦截路径
//        registry.addInterceptor(new JwtInterceptor())
//                .addPathPatterns(pathArray); // 设置需要拦截的请求路径
    }

}